home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS04.ADF / idemo / idemo.c < prev    next >
C/C++ Source or Header  |  1985-10-26  |  44KB  |  1,408 lines

  1. /****************************************************************
  2. *                                                               *
  3. * Copyright 1985, Commodore Amiga Inc.  All rights reserved.    *
  4. * No part of this program may be reproduced, transmitted,       *
  5. * transcribed, stored in retrieval system, or translated into   *
  6. * any language or computer language, in any form or by any      *
  7. * means, electronic, mechanical, magnetic, optical, chemical,   *
  8. * manual or otherwise, without the prior written permission of  *
  9. * Commodore Amiga Incorporated, 983 University Ave, #D          *
  10. * Los Gatos, CA 95030                                           *
  11. *                                                               *
  12. ****************************************************************/
  13.  
  14. /*** idemo.c ***/
  15.  
  16. /*****************************************************************************
  17.  *
  18.  * INTUITION Test Suite
  19.  *
  20.  * =Robert J. Mical=
  21.  * 28 April 1985
  22.  * (created:  31 January 1985)
  23.  *
  24.  * At one time or another, this program has tested all of the INTUITION 
  25.  * features, and sometimes has tested even the limits of my patience.
  26.  * 
  27.  * CONFIDENTIAL and PROPRIETARY
  28.  * Copyright (C) 1985, COMMODORE-AMIGA, INC.
  29.  * All Rights Reserved
  30.  *
  31.  *
  32.  *****************************************************************************
  33.  *
  34.  * This program is not the neatest bit of code I've ever written. 
  35.  * I'm a busy guy, you know?  I do my best, especially considering that
  36.  * this is a rag-tag program that I've been using since the beginning to work 
  37.  * out the INTUITION details, so it's grown by jerks and splats.
  38.  * This program is naughty.  It reuses Requesters capriciously.  It's a test
  39.  * program for INTUITION functionality, after all, not a polished work of
  40.  * software.  Don't be surprised if things get fouled up should you try 
  41.  * to do very convoluted things with this code.  Make sure your own software
  42.  * is much more careful and consistent than the following code.  =RJ=
  43.  *
  44.  *****************************************************************************
  45.  *
  46.  * NOTE:  for a summary of all the commands you have available to you in this
  47.  * program, please refer to the file idemo.guide.  All of the case statements
  48.  * are listed in that file, just for you!
  49.  *
  50.  ****************************************************************************/
  51.  
  52.  
  53.  
  54. #include "idemoall.h"
  55.  
  56.  
  57. #define SELECTUP        (IECODE_LBUTTON | IECODE_UP_PREFIX)
  58. #define SELECTDOWN      IECODE_LBUTTON
  59. #define MENUUP          (IECODE_RBUTTON | IECODE_UP_PREFIX)
  60. #define MENUDOWN        IECODE_RBUTTON
  61. #define HALFMILLION     500000
  62.  
  63. /* these produce an 8-1/2 wide dump on the Diablo C150 */
  64. #define DUMP_WIDTH 1024
  65. #define DUMP_HEIGHT 640
  66.  
  67. extern struct Menu menus[2][7]; /* defined in demomenu.c */
  68. extern struct MenuItem items[]; /* defined in demomenu.c */
  69. extern struct Menu IslandMenu;  /* defined in demomenu2.c */
  70. extern struct Requester TestRequest[];  /* defined in demoreq.c */
  71. extern struct Gadget BoolGadget;        /* defined in demoreq.c */
  72. extern struct Gadget ReqProp;           /* defined in demoreq.c */
  73.  
  74. struct GfxBase *GfxBase;
  75. struct IntuitionBase *IntuitionBase;
  76.  
  77. UBYTE AlertString[] =
  78. "\0\210\15ALERT:  System Out of Memory Error\0\1\
  79. \0\10\32Press Left Button to Retry\0\1\
  80. \1\150\32Press Right Button to Abort\0\1\
  81. \0\214\47Guru Meditation Number 0x87000005\0"; /* c puts the extra NULL */
  82.  
  83. UBYTE *AllocRaster();
  84. struct Window *OpenWindow();
  85. struct Screen *OpenScreen();
  86. struct menuItem *ItemAddress();
  87. UBYTE GetKey();
  88. BOOL DisplayAlert();
  89.  
  90. USHORT red = 5;         /* pseudo-random Screen colors */
  91. USHORT green = 10;      /* pseudo-random Screen colors */
  92. USHORT blue = 15;       /* pseudo-random Screen colors */
  93.  
  94. struct Window *RecentWindow;    /* for anyone who wants the most recent */
  95. struct Screen *StartupScreen;   
  96.  
  97. SHORT screenindex;
  98.  
  99. UBYTE *ScreenTitles[] =
  100.     {
  101.     "A Matter of Intuition",
  102.     "=VoodooDrRj= Screen Title",
  103.     "Good Day, Ice Cream",
  104.     "Like These Colors Screen",
  105.     };
  106.  
  107.  
  108. #include "../intuition/intuinternal.h"
  109.  
  110. struct IntuiText BodyText2 =
  111.     {
  112.     0, 1, 
  113.     JAM2,
  114.     15, 25,
  115.     NULL,
  116.     " HEY!  Pay Attention! ",
  117.     NULL,
  118.     };
  119.  
  120. struct IntuiText BodyText1 =
  121.     {
  122.     0, 1, 
  123.     JAM2,
  124.     15, 10,
  125.     NULL,
  126.     "Body Text Line For You",
  127.     &BodyText2,
  128.     };
  129.  
  130. struct IntuiText GoodText =
  131.     {
  132.     AUTOFRONTPEN, AUTOBACKPEN, 
  133.     AUTODRAWMODE,
  134.     AUTOLEFTEDGE, AUTOTOPEDGE,
  135.     AUTOITEXTFONT,
  136.     "Favorable",
  137.     AUTONEXTTEXT,
  138.     };
  139.  
  140. struct IntuiText BadText =
  141.     {
  142.     AUTOFRONTPEN, AUTOBACKPEN, 
  143.     AUTODRAWMODE,
  144.     AUTOLEFTEDGE, AUTOTOPEDGE,
  145.     AUTOITEXTFONT,
  146.     "Unfavorable",
  147.     AUTONEXTTEXT,
  148.     };
  149.  
  150.  
  151.     
  152. /* ======================================================================== */
  153. /* === Demo Toggle Gadget ================================================= */
  154. /* ======================================================================== */
  155.  
  156. USHORT ToggleData[] =
  157.     {
  158.     0xFFFF, 0xF000,
  159.     0x5555, 0x5000,
  160.     0xFFFF, 0xF000,
  161.     0x5555, 0x5000,
  162.     0xFFFF, 0xF000,
  163.     0x5555, 0x5000,
  164.     0xFFFF, 0xF000,
  165.     0x5555, 0x5000,
  166.     0xFFFF, 0xF000,
  167.     0x5555, 0x5000,
  168.     };
  169.  
  170. struct Image ToggleImage = 
  171.     {
  172.     0, 0,               /* LeftEdge, TopEdge */
  173.     20, 10, 1,          /* Width, Height, Depth */
  174.     ToggleData,         /* ImageData */
  175.     0x2, 0x1,           /* PlanePick, PlaneOnOff */
  176.     };
  177.  
  178. struct Gadget ToggleGadget =
  179.     {
  180.     NULL,       /* Next Gadget */
  181.     20, 10, 20, 10,             /* (Left Top Width Height */
  182.     GADGHBOX | SELECTED | GADGIMAGE,    /* Flags */
  183.     GADGIMMEDIATE | RELVERIFY | TOGGLESELECT,   /* Activation flags */
  184.     BOOLGADGET,                         /* Type */
  185.     &ToggleImage,       /* Border Image */
  186.     NULL,       /* no SelectRender */
  187.     NULL,       /* no GadgetText */
  188.     0,          /* no MutualExclude */
  189.     NULL,       /* no SpecialInfo */
  190.     NULL,       /* no ID */
  191.     NULL,       /* no special data */
  192.     };
  193.  
  194.  
  195.  
  196. /* ======================================================================== */
  197. /* === String Gadget ====================================================== */
  198. /* ======================================================================== */
  199.  
  200. USHORT StrVectors[] =
  201.     {
  202.     0, 0,
  203.     208, 0,
  204.     208, 12,
  205.     0, 12,
  206.     0, 0,
  207.     207, 0,
  208.     207, 12,
  209.     1, 12,
  210.     1, 0,
  211.     };
  212.  
  213. struct Border StrBorder = 
  214.     {
  215.     -4, -2,     /* initial offsets */
  216.     1, 0, JAM1, /* pens and drawmode */
  217.     9,          /* number of vectors */
  218.     StrVectors, /* pointer to the actual array of vectors */
  219.     NULL,       /* next Border */
  220.     };
  221.  
  222. /*???#define STRINGSIZE 100*/
  223. #define STRINGSIZE 5
  224.  
  225. /*???UBYTE StrBuffer[STRINGSIZE] = "String Gadgetry available now under Intuition";*/
  226. UBYTE StrBuffer[STRINGSIZE] = "";
  227. UBYTE UndoBuffer[STRINGSIZE];
  228.  
  229. struct StringInfo StrInfo =
  230.     {
  231.     StrBuffer,  /* input buffer */
  232.     UndoBuffer, /* undo buffer */
  233.     0,          /* buffer position */
  234.     STRINGSIZE, /* maximum number of chars, including trailing NULL */
  235.     0, 0,       /* display, undo positions */
  236.     0,          /* number of chars in the buffer */
  237.     0, 0, 0,    /* position variables calculated by Intuition */
  238.     NULL,       /* RastPort pointer */
  239.     NULL,       /* LongInt */
  240.     };
  241.  
  242. struct IntuiText StrText =
  243.     {
  244.     1, 0, 
  245.     JAM2,
  246.     55, 0,
  247.     NULL,
  248.     "DaveBTest",
  249.     NULL,
  250.     };
  251.  
  252. struct Gadget StringGadget =
  253.     {
  254.     NULL,       /* Next Gadget */
  255.     10, 15, 201, 10,            /* (Left Top (rel)Width Height */
  256.     GADGHCOMP,  /* Flags */
  257. /*???    LONGINT | STRINGCENTER | RELVERIFY,    /* Activation flags */
  258.     STRINGRIGHT | RELVERIFY,    /* Activation flags */
  259.     STRGADGET,                          /* Type */
  260.     &StrBorder, /* Border Image */
  261. /*???    NULL,          /* Border Image */
  262.     NULL,       /* no SelectRender */
  263. /*???    NULL,  /* no GadgetText */
  264.     &StrText,   /* no GadgetText */
  265.     0,          /* no MutualExclude */
  266.     &StrInfo,   /* SpecialInfo proportional data filled in later */
  267.     NULL,       /* no ID */
  268.     NULL,       /* no special data */
  269.     };
  270.  
  271.  
  272.  
  273. /* ======================================================================== */
  274. /* === Proportional Gadgets in Window Borders ============================= */
  275. /* ======================================================================== */
  276.  
  277. /* the following variables are used to create proportional Gadgets that
  278.  * will appear on the borders of opening Windows.  These variables will
  279.  * be filled in with copies of the generic Gadgetry below
  280.  */
  281. SHORT PropCount;        /* index to next available Gadget */
  282. #define PROPMAX 20      /* maximum number of Gadgets */
  283. struct Image PropImage[PROPMAX];        /* dummy AUTOKNOB Images */
  284. struct Gadget Props[PROPMAX];           /* these get copies of PropGadget */
  285. struct PropInfo PInfos[PROPMAX];        /* these get copies of TestProp */
  286.  
  287. /* this is the template for the PropInfo of a Proportional Gadget */
  288. struct PropInfo TestPropInfo =
  289.     {
  290.     AUTOKNOB,                   /* Flags:  has no FREEdom yet */
  291.     0, 0,                       /* Pots:  both start at 0 */
  292.     0x5555, 0x3FFF,             /* Bodies: Horiz is 1/3, Vert is 1/4 */
  293.     0, 0, 0, 0, 0, 0,           /* System usage stuff */
  294.     };
  295.  
  296. /* this is the template for the Gadget of a vertical Proportional Gadget */
  297. struct Gadget VPropGadget =
  298.     {
  299.     NULL,                       /* NextGadget */
  300.     -15, 10, 16, -9-10,         /* (rel)Left Top Width (rel)Height */
  301.     GADGHCOMP | GADGIMAGE | GRELRIGHT | GRELHEIGHT, /* Flags */
  302.     GADGIMMEDIATE | RIGHTBORDER | RELVERIFY,    /* Activation flags */
  303.     PROPGADGET,                         /* Type */
  304.     NULL,       /* Image filled in later with dummy since this is AUTOKNOB */
  305.     NULL,       /* no SelectRender */
  306.     NULL,       /* no GadgetText */
  307.     0,          /* no MutualExclude */
  308.     NULL,       /* SpecialInfo proportional data filled in later */
  309.     NULL,       /* no ID */
  310.     NULL,       /* no special data */
  311.     };
  312.  
  313.  
  314. /* this is the template for the Gadget of a horizontal Proportional Gadget */
  315. struct Gadget HPropGadget =
  316.     {
  317.     NULL,               /* NextGadget */
  318.     0, -8, -15, 9,      /* Select Box Left (rel)Top (rel)Width Height */
  319.     GADGHCOMP | GADGIMAGE | GRELWIDTH | GRELBOTTOM, /* Flags */
  320.     GADGIMMEDIATE | BOTTOMBORDER | RELVERIFY,   /* Activation flags */
  321.     PROPGADGET,                         /* Type */
  322.     NULL,       /* Image filled in later since this is AUTOKNOB */
  323.     NULL,       /* no SelectRender */
  324.     NULL,       /* no GadgetText */
  325.     0,          /* no MutualExclude */
  326.     NULL,       /* SpecialInfo proportional data filled in later */
  327.     NULL,       /* no ID */
  328.     NULL,       /* no special data */
  329.     };
  330.  
  331. /* ======================================================================== */
  332. /* ======================================================================== */
  333. /* ======================================================================== */
  334.  
  335. /* my own little pointer */
  336. #define POINTHEIGHT 9
  337. #define POINTWIDTH 9
  338. #define PXOFFSET -4
  339. #define PYOFFSET -4
  340.  
  341. USHORT Pointer[] = 
  342.     {
  343.     0x0000, 0x0000,     /* one word each for position and control */
  344.  
  345.     0xC180, 0x4100,
  346.     0x6380, 0xA280,
  347.     0x3700, 0x5500,
  348.     0x1600, 0x2200,
  349.     0x0000, 0x0000,
  350.     0x1600, 0x2200,
  351.     0x2300, 0x5500,
  352.     0x4180, 0xA280,
  353.     0x8080, 0x4100,
  354.  
  355.     0x0000, 0x0000,
  356.     0x0000, 0x0000,
  357.     };
  358.  
  359.  
  360. /* my own font descriptor */
  361. struct TextAttr TestFont =
  362.     {
  363.     "topaz.font",       /* Font Name */
  364.  
  365. /* by changing the font height between 8 and 9, you get 80-col and 64-col
  366.  * fonts respectively 
  367.  */
  368.     8,  /* Font Height */
  369.  
  370.     FS_NORMAL,  /* Style */
  371.     FPF_ROMFONT,        /* Preferences */
  372.     };
  373.  
  374.  
  375. /* my own font descriptor */
  376. struct TextAttr TopazSixty =
  377.     {
  378.     "topaz.font",       /* Font Name */
  379.  
  380. /* by changing the font height between 8 and 9, you get 80-col and 64-col
  381.  * fonts respectively 
  382.  */
  383.     TOPAZ_SIXTY,        /* Font Height */
  384.  
  385.     FS_NORMAL,  /* Style */
  386.     FPF_ROMFONT,        /* Preferences */
  387.     };
  388.  
  389.  
  390. /* ======================================================================== */
  391. /* === Assorted Window Titles ============================================= */
  392. /* ======================================================================== */
  393.  
  394. BYTE *WindowTitle[] =
  395.     {
  396.         "=>RJ<=",
  397.         " Test Window #347812678111",
  398.         "Normal Pens Window",
  399.         "BADOOLIE Breath",
  400.         "Your Own Window Specifications",
  401.         "From Here To Katmandu",
  402.         "Big City Word Processor",
  403.     };
  404.  
  405.  
  406. /* ======================================================================== */
  407. /* === General Purpose Window Task ======================================== */
  408. /* ======================================================================== */
  409.  
  410. windowtask(screen)
  411. struct Screen *screen;
  412. /* The windowtask starts out by opening a Window of your design.  It can
  413.  * then accept input from the IDCMP, depending on your preferences
  414.  * The screen arg can either point to a CUSTOM SCREEN or be NULL (which
  415.  * means we're still under WorkBench)
  416.  */
  417. {
  418.     SHORT top, left, width, height, windownum, detailpen, blockpen;
  419.     ULONG flags, idcmp;
  420.     struct Window *w;
  421.     SHORT pointer;
  422.     BOOL vprop, hprop;
  423.     struct IntuiMessage *message;
  424.     SHORT toll;
  425.     struct Gadget *newgadgets;
  426.     struct NewWindow NewWindow;
  427.     UBYTE *title;
  428.     struct Task *task;
  429.  
  430.     task = (struct Task *)FindTask(0);
  431.  
  432.     printf("***New Task:  lower=%lx current=%lx upper=%lx\n",
  433.             task->tc_SPLower, &task, task->tc_SPUpper);
  434.     printf("OPENING A WINDOW:\n");
  435.     printf("   Select a Window Preset number (or 'x' to create your own) : ");
  436.     windownum = GetNum();
  437.     printf("\n");
  438.  
  439.     switch (windownum)
  440.         {
  441.         case 0:
  442.                 left = 10;
  443.                 top = 84;
  444.                 width = 200;
  445.                 height = 59;
  446.                 detailpen = 3;
  447.                 blockpen = 2;
  448.                 title = WindowTitle[windownum];
  449.                 flags = GIMMEZEROZERO | WINDOWDEPTH | WINDOWSIZING 
  450.                                 | WINDOWDRAG | WINDOWCLOSE | SMART_REFRESH;
  451.                 idcmp = RAWKEY | CLOSEWINDOW | MOUSEMOVE | MENUVERIFY 
  452.                         | NEWPREFS;
  453.                 hprop = TRUE;
  454.                 vprop = TRUE;
  455.                 break;
  456.         case 1:
  457.                 left = 65;
  458.                 top = 53;
  459.                 width = 200;
  460.                 height = 128;
  461.                 detailpen = 0;
  462.                 blockpen = 2;
  463.                 title = WindowTitle[windownum];
  464.                 flags = ACTIVATE | WINDOWDEPTH | WINDOWSIZING
  465.                                 | WINDOWDRAG | WINDOWCLOSE | SIMPLE_REFRESH;
  466.                 idcmp = RAWKEY | MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN
  467.                         | GADGETUP | MENUPICK | CLOSEWINDOW 
  468.                         | SIZEVERIFY | NEWSIZE | MENUVERIFY
  469.                         | NEWPREFS;
  470.                 hprop = FALSE;
  471.                 vprop = TRUE;
  472.                 break;
  473.         case 2:
  474.                 left = 0;
  475.                 top = 5;
  476. /*???           top = 25;*/
  477.                 width = 320;
  478.                 height = 150;
  479.                 detailpen = 0;
  480.                 blockpen = 1;
  481.                 title = WindowTitle[windownum];
  482.                 flags = WINDOWDEPTH | WINDOWDRAG | WINDOWSIZING | WINDOWCLOSE 
  483.                         | BACKDROP | SMART_REFRESH;
  484.                 idcmp = MENUPICK | CLOSEWINDOW | MENUVERIFY
  485.                         | NEWPREFS;
  486.                 hprop = TRUE;
  487.                 vprop = FALSE;
  488.                 break;
  489.         case 3:
  490.                 left = 0;
  491.                 top = 10;
  492.                 width = 300;
  493.                 height = 90;
  494.                 detailpen = -1;
  495.                 blockpen = -1;
  496.                 title = WindowTitle[windownum];
  497.                 flags = ACTIVATE | WINDOWDRAG | SMART_REFRESH;
  498.                 idcmp = GADGETUP | MENUVERIFY
  499.                         | NEWPREFS;
  500.                 hprop = FALSE;
  501.                 vprop = FALSE;
  502.                 break;
  503.         case 4:
  504.                 left = 0;
  505.                 top = 0;
  506.                 if (screen) width = 320;
  507.                 else width = 640;
  508.                 height = 200;
  509.                 detailpen = -1;
  510.                 blockpen = -1;
  511.                 title = NULL;
  512.                 flags = BACKDROP | SIMPLE_REFRESH;
  513.                 idcmp = GADGETDOWN | GADGETUP | MENUVERIFY
  514.                         | REQVERIFY | RAWKEY
  515.                         | NEWPREFS;
  516.                 hprop = FALSE;
  517.                 vprop = FALSE;
  518.                 break;
  519.         case 5:
  520.                 left = 100;
  521.                 top = 100;
  522.                 width = 220;
  523.                 height = 100;
  524.                 detailpen = 2;
  525.                 blockpen = 3;
  526.                 title = WindowTitle[windownum];
  527.                 flags = SMART_REFRESH | RMBTRAP
  528.                         | WINDOWDEPTH | WINDOWSIZING 
  529.                         | WINDOWDRAG | WINDOWCLOSE;
  530.                 idcmp = GADGETDOWN | GADGETUP
  531.                         | RAWKEY | REFRESHWINDOW
  532.                         | NEWPREFS | MOUSEBUTTONS | CLOSEWINDOW;
  533.                 hprop = FALSE;
  534.                 vprop = FALSE;
  535.                 break;
  536.         case 6:
  537.                 left = 100;
  538.                 top = 100;
  539.                 width = 220;
  540.                 height = 100;
  541.                 detailpen = -1;
  542.                 blockpen = -1;
  543.                 title = WindowTitle[windownum];
  544.                 flags = SMART_REFRESH 
  545.                         | WINDOWDEPTH | WINDOWSIZING 
  546.                         | WINDOWDRAG | WINDOWCLOSE;
  547.                 idcmp = GADGETDOWN | GADGETUP
  548.                         | RAWKEY | REFRESHWINDOW
  549.                         | NEWPREFS | MOUSEBUTTONS | CLOSEWINDOW;
  550.                 hprop = TRUE;
  551.                 vprop = TRUE;
  552.                 break;
  553.         case 8:
  554.                 left = 10;
  555.                 top = 84;
  556.                 width = 200;
  557.                 height = 59;
  558.                 detailpen = -1;
  559.                 blockpen = -1;
  560.                 title = WindowTitle[0];
  561.                 flags = GIMMEZEROZERO | WINDOWDEPTH | WINDOWSIZING 
  562.                                 | WINDOWDRAG | WINDOWCLOSE | SMART_REFRESH;
  563.                 idcmp = RAWKEY | CLOSEWINDOW | MOUSEMOVE | MENUVERIFY 
  564.                         | NEWPREFS;
  565.                 hprop = TRUE;
  566.                 vprop = TRUE;
  567.                 break;
  568.         default:
  569.                 windownum = 6;
  570.                 printf("\n       left = ");
  571.                 left = GetNum();
  572.                 printf("\n        top = ");
  573.                 top = GetNum();
  574.                 printf("\n      width = ");
  575.                 width = GetNum();
  576.                 printf("\n     height = ");
  577.                 height = GetNum();
  578.                 printf("\n  detailpen = ");
  579.                 detailpen = GetNum();
  580.                 printf("\n   blockpen = ");
  581.                 blockpen = GetNum();
  582.                 printf("\n      flags = ");
  583.                 flags = GetNum();
  584.                 printf("\n      idcmp = ");
  585.                 idcmp = GetNum();
  586.                 printf("\n      horizontal prop gadget = ");
  587.                 hprop = GetNum();
  588.                 printf("\n        vertical prop gadget = ");
  589.                 vprop = GetNum();
  590.                 break;
  591.         }
  592.  
  593.     newgadgets = NULL;
  594.  
  595.     if (vprop)
  596.         {
  597.         if (flags & WINDOWSIZING) flags |= SIZEBBOTTOM;
  598.         Props[PropCount] = VPropGadget;
  599.         PInfos[PropCount] = TestPropInfo;
  600.         PInfos[PropCount].Flags |= FREEVERT;
  601.         Props[PropCount].GadgetRender = &PropImage[PropCount];
  602.         Props[PropCount].SpecialInfo = &PInfos[PropCount];
  603.         newgadgets = &Props[PropCount++];
  604.         }
  605.     if (hprop)
  606.         {
  607.         if (flags & WINDOWSIZING) flags |= SIZEBRIGHT;
  608.         Props[PropCount] = HPropGadget;
  609.         if ((windownum == 0) || (windownum == 8))
  610.             Props[PropCount].GadgetType |= GZZGADGET;
  611.         PInfos[PropCount] = TestPropInfo;
  612.         PInfos[PropCount].Flags |= FREEHORIZ;
  613.         Props[PropCount].GadgetRender = &PropImage[PropCount];
  614.         Props[PropCount].SpecialInfo = &PInfos[PropCount];
  615.         if (newgadgets) newgadgets->NextGadget = &Props[PropCount++];
  616.         else newgadgets = &Props[PropCount++];
  617.         }
  618.  
  619.     if (windownum == 1)
  620.         {
  621. /*???printf("%ToggleGadget=%lx\n",&ToggleGadget);*/
  622. /*???   if (newgadgets) newgadgets->NextGadget = &ToggleGadget;*/
  623. /*???   else newgadgets = &ToggleGadget;*/
  624.         }
  625.  
  626.     if (windownum == 3)
  627.         {
  628.         if (newgadgets) newgadgets->NextGadget = &StringGadget;
  629.         else newgadgets = &StringGadget;
  630.         printf("&Activation=%lx\n",&StringGadget.Activation);
  631.         }
  632.  
  633.     NewWindow.LeftEdge = left;
  634.     NewWindow.TopEdge = top;
  635.     NewWindow.Width = width;
  636.     NewWindow.Height = height;
  637.     NewWindow.DetailPen = detailpen;
  638.     NewWindow.BlockPen = blockpen;
  639.     NewWindow.Title = title;
  640.     NewWindow.Flags = flags;
  641.     NewWindow.IDCMPFlags = idcmp;
  642.     if (screen) NewWindow.Type = CUSTOMSCREEN;
  643.     else NewWindow.Type = WBENCHSCREEN;
  644.     NewWindow.FirstGadget = newgadgets;
  645.     NewWindow.CheckMark = NULL;
  646.     NewWindow.Screen = screen;
  647.     NewWindow.BitMap = NULL;
  648.     NewWindow.MinWidth = width - 20;
  649.     NewWindow.MinHeight = height - 20;
  650.     NewWindow.MaxWidth = width + 20;
  651.     NewWindow.MaxHeight = height + 20;
  652.  
  653.     if ((windownum <= 0) || (windownum >= 5))
  654.         {
  655.         NewWindow.MinHeight = height;
  656.         NewWindow.MaxWidth = 32767;
  657.         NewWindow.MaxHeight = 32767;
  658.         }
  659.  
  660.     if ((w = OpenWindow(&NewWindow)) == NULL) 
  661.         {
  662.         printf("\nMAYDAY MAYDAY:  couldn't open that Window!\n");
  663.         RemTask(0);
  664.         }
  665.     printf("Your Window structure is at location %lx\n", w);
  666.     RecentWindow = w;   /* assign it to the global variable */
  667.  
  668.     if (windownum != 6) SetMenuStrip(w, &menus[windownum & 1][0]);
  669.     else SetMenuStrip(w, &menus[1][0]);
  670.  
  671. /*???    if (windownum) SetDMRequest(w, &TestRequest[1 - (windownum & 1)]);*/
  672.     SetDMRequest(w, &TestRequest[1 - (windownum & 1)]);
  673.  
  674.     if (windownum == 1)
  675.         SetPointer(w, Pointer, POINTHEIGHT, POINTWIDTH, PXOFFSET, PYOFFSET);
  676.  
  677.     toll = 3;
  678.  
  679.     /* now hang around waiting for news on the IDCMP */
  680.     FOREVER
  681.         {
  682.         Wait(1 << w->UserPort->mp_SigBit);
  683.  
  684.         while (message = (struct IntuiMessage *)GetMsg(w->UserPort))
  685.             {
  686.             printf("message=%lx Class=%lx Code=%lx X=%ld Y=%ld\n",
  687.                     message, message->Class, message->Code, 
  688.                     message->MouseX, message->MouseY);
  689.             switch (message->Class)
  690.                 {
  691.                 case REFRESHWINDOW:
  692.                         printf("REFRESHWINDOW=%lx\n", w);
  693.                         BeginRefresh(w);
  694.                         EndRefresh(w, TRUE);
  695.                         break;
  696.                 case RAWKEY: getansi(message, w); break;
  697.                 case GADGETUP: gadgetmessage(message, w); break;
  698.                 case SIZEVERIFY: sizeverify(message, w);  break;
  699.                 case NEWSIZE: newsize(message, w);  break;
  700.                 case REQVERIFY: dmreqverify(message, w); break;
  701.                 case MENUVERIFY: menuverify(windownum, message, w); break;
  702.                 case MENUPICK: setmenus(message, w); break;
  703.                 case MOUSEBUTTONS: mousebuttons(message, w); break;
  704.                 case CLOSEWINDOW:
  705.                         if ((toll = closewindow(message, w, toll)) == 0)
  706.                             {
  707.                             if (screen) if (screen->FirstWindow == NULL)
  708.                                 {
  709.                                 printf("trying to close Screen %lx ", screen);
  710.                                 CloseScreen(screen);
  711.                                 printf("and succeeding!\n");
  712.                                 }
  713.                             /* that's it, time to exit this Window task */
  714.                             /* this is naughty, it should free its stack */
  715.                             RemTask(0);
  716.                             }
  717.                         /* else, we still continue on */
  718.                         break;
  719.                 default:  ReplyMsg(message);  break;
  720.                 }
  721.             }
  722.         }
  723. }
  724.  
  725.  
  726. mousebuttons(message, w)
  727. struct IntuiMessage *message;
  728. struct Window *w;
  729. {
  730.     switch (message->Code)
  731.         {
  732.         case MENUDOWN: printf("MENUDOWN received\n"); break;
  733.         case MENUUP: printf("MENUUP received\n"); break;
  734.         case SELECTDOWN: printf("SELECTDOWN received\n"); break;
  735.         case SELECTUP: printf("SELECTUP received\n"); break;
  736.         default:  printf("WEIRD %lx received\n",message->Code); break;
  737.         }
  738.  
  739.     ReplyMsg(message);
  740. }
  741.  
  742.  
  743.  
  744. menuverify(windownum, message, w)
  745. USHORT windownum;
  746. struct IntuiMessage *message;
  747. struct Window *w;
  748. {
  749.     if (message->Code == MENUHOT)
  750.         {
  751.         /* this one must be the active Window
  752.          * set it only for Window 0, which requires the Pointer to
  753.          * be at or above the Screen Title Bar
  754.          */
  755.         if ((windownum == 0) && (w->WScreen->MouseY > 10))
  756.             message->Code = MENUCANCEL;
  757.         }
  758.  
  759.     ReplyMsg(message);
  760. }
  761.  
  762.  
  763.  
  764. gadgetmessage(message, w)
  765. struct IntuiMessage *message;
  766. struct Window *w;
  767. {
  768.     struct Gadget *g;
  769.     printf("GADGETUP GOTTEN, for Gadget at %lx\n",message->IAddress);
  770.     g = (struct Gadget *)message->IAddress;
  771.     if (g->Activation & LONGINT)
  772.         {
  773.         printf("   LONGINT with value = %ld\n",
  774.                 (LONG)((struct StringInfo *)g->SpecialInfo)->LongInt);
  775.         }
  776.     ReplyMsg(message);
  777. }
  778.  
  779.  
  780. getansi(message, w)
  781. struct IntuiMessage *message;
  782. struct Window *w;
  783. {
  784.     UBYTE character;
  785.     USHORT pen, rgb, red, green, blue;
  786.     struct Preferences prefs;
  787.  
  788.     if (character = GetKey(message))
  789.         printf("%lc", character);
  790.  
  791.     ReplyMsg(message);
  792.  
  793.     switch (character)
  794.         {
  795.         case 'a':
  796.             RemoveGadget(w, &ToggleGadget);
  797.             RefreshGadgets(w->FirstGadget, w);
  798.             if (ToggleGadget.Flags & SELECTED)ToggleGadget.Flags &= ~SELECTED;
  799.             else ToggleGadget.Flags |= SELECTED;
  800.             break;
  801.         case 'A':
  802.             AddGadget(w, &ToggleGadget, -1);
  803.             RefreshGadgets(w->FirstGadget, w);
  804.             break;
  805.         case 'c':
  806.             printf("What pen number: ");  pen = GetNum();
  807.             rgb = GetRGB4(w->WScreen->ViewPort.ColorMap, pen);
  808.             red = (rgb >> 8) & 0xF;
  809.             green = (rgb >> 4) & 0xF;
  810.             blue = (rgb) & 0xF;
  811.             printf("\nRed=%ld.  What value for red: ", red);  
  812.             red = GetNum();
  813.             printf("\nGreen=%ld.  What value for green: ", green);  
  814.             green = GetNum();
  815.             printf("\nBlue=%ld.  What value for blue: ", blue);  
  816.             blue = GetNum();
  817.             SetRGB4(&w->WScreen->ViewPort, pen, red, green, blue);
  818.             break;
  819.         case 'i':
  820.         case 'I':
  821.             TestITLength();
  822.         case 'p':
  823.         case 'P':
  824.             GetDefPrefs(&prefs, sizeof(struct Preferences));
  825.             printf("&prefs=%lx\n",&prefs);
  826.             Debug();
  827.             break;
  828.         case 'R':
  829.             Request(&TestRequest[2], w);
  830.             break;
  831.         case 's':
  832.             ShowTitle(w->WScreen, FALSE);
  833.             break;
  834.         case 'S':
  835.             ShowTitle(w->WScreen, TRUE);
  836.             break;
  837.         case 'T':
  838.             SetWindowTitles(w, "Here's a new Window Title",
  839.                 "The Big-T Screen Title");
  840.             break;
  841.         case 't':
  842.             SetWindowTitles(w, -1, "The little-t Screen Title");
  843.             break;
  844.         case 'w':
  845.             WindowToBack(w);
  846.             break;
  847.         case 'W':
  848.             WindowToFront(w);
  849.             break;
  850.         case 'x':
  851.             SizeWindow(w, -2, 0);
  852.             break;
  853.         case 'X':
  854.             SizeWindow(w, 2, 0);
  855.             break;
  856.         case 'y':
  857.             SizeWindow(w, 0, -1);
  858.             break;
  859.         case 'Y':
  860.             SizeWindow(w, 0, 1);
  861.             break;
  862.         case '1':
  863.             WBenchToBack();
  864.             break;
  865.         case '!':
  866.             WBenchToFront();
  867.             break;
  868.         case '-':
  869.             MoveWindow(w, -2, 0);
  870.             break;
  871.         case '_':
  872.             MoveWindow(w, 2, 0);
  873.             break;
  874.         case '=':
  875.             MoveWindow(w, 0, -1);
  876.             break;
  877.         case '+':
  878.             MoveWindow(w, 0, 1);
  879.             break;
  880.         }
  881.  
  882. }
  883.  
  884.  
  885.  
  886. TestITLength()
  887. {
  888.     struct IntuiText itext;
  889.  
  890.     itext.ITextFont = NULL;
  891.     itext.IText = "=VoodooDrRj=";
  892.     printf("Pixel width with default font is %ld\n", IntuiTextLength(&itext));
  893.     itext.ITextFont = &TestFont;
  894.     printf("Pixel width with TestFont is %ld\n", IntuiTextLength(&itext));
  895.     itext.IText = "";
  896.     printf("Pixel width with null string is %ld\n", IntuiTextLength(&itext));
  897. }
  898.  
  899.  
  900.  
  901. setmenus(message, w)
  902. struct IntuiMessage *message;
  903. struct Window *w;
  904. {
  905.     struct Menu *menu;
  906.     struct MenuItem *nextitem, *subitem;
  907.     USHORT nextnum;
  908.  
  909.     if ((nextnum = message->Code) == MENUNULL) return;
  910.  
  911.     nextitem = ItemAddress(w->MenuStrip, nextnum);
  912.  
  913.     do
  914.         {
  915.         printf("*** Menu=%ld Item=%ld Sub=%ld\n",
  916.                 MENUNUM(nextnum), ITEMNUM(nextnum), SUBNUM(nextnum));
  917.         setMenuGrunt(nextitem, nextnum, w);
  918.         nextnum = nextitem->NextSelect;
  919.         nextitem = ItemAddress(w->MenuStrip, nextnum);
  920.         }
  921.     while (nextitem);
  922.  
  923.     /* now check if all are turned off yet, and if so turn them all on */
  924.     /* if I find an enabled item anywhere, return immediately */
  925.     /* if I make it to the end, all items are disabled */
  926.     menu = w->MenuStrip;
  927.     do
  928.         {
  929.         nextitem = menu->FirstItem;
  930.         while (nextitem)
  931.             {
  932.             if (subitem = nextitem->SubItem)
  933.                 {
  934.                 while (subitem)
  935.                     {
  936.                     if (subitem->Flags & ITEMENABLED) return;
  937.                     subitem = subitem->NextItem;
  938.                     }
  939.                 }
  940.             else /* there's no subitems, so check this item itself */
  941.                 if (nextitem->Flags & ITEMENABLED) return;
  942.             nextitem = nextitem->NextItem;
  943.             }
  944.         menu = menu->NextMenu;
  945.         }
  946.     while(menu);
  947.  
  948.     printf("OK, all items disabled.  Enabling everyone now ... ");
  949.     menu = w->MenuStrip;
  950.     do
  951.         {
  952.         menu->Flags |= MENUENABLED;
  953.         nextitem = menu->FirstItem;
  954.         while (nextitem)
  955.             {
  956.             if (subitem = nextitem->SubItem)
  957.                 {
  958.                 while (subitem)
  959.                     {
  960.                     subitem->Flags |= ITEMENABLED;
  961.                     subitem = subitem->NextItem;
  962.                     }
  963.                 }
  964.             else /* there's no subitems, so check this item itself */
  965.                 nextitem->Flags |= ITEMENABLED;
  966.  
  967.             nextitem = nextitem->NextItem;
  968.             }
  969.  
  970.         menu = menu->NextMenu;
  971.         }
  972.     while(menu);
  973.     printf("done!\n");
  974. }
  975.  
  976.  
  977. setMenuGrunt(item, menunum, w)
  978. struct MenuItem *item;
  979. USHORT menunum;
  980. struct Window *w;
  981. {
  982.     /* now, item points to the MenuItem that we want to disable */
  983.     if ((item->Flags & ITEMENABLED) == NULL)
  984.         {
  985.         printf("Hey, that item was disabled!  How did that happen?\n");
  986.         Debug();
  987.         }
  988.     OffMenu(w, menunum);
  989. }
  990.  
  991.  
  992.  
  993. dmreqverify(message, w)
  994. struct IntuiMessage *message;
  995. struct Window *w;
  996. {
  997.     SHORT count;
  998.  
  999.     printf("REQ?  Well...");
  1000.     for (count = 65535; count; count--) ;
  1001.     printf("well...");
  1002.     for (count = 65535; count; count--) ;
  1003.     printf("well...");
  1004.     for (count = 65535; count; count--) ;
  1005.     printf("well...");
  1006.     for (count = 65535; count; count--) ;
  1007.     printf("OK!\n");
  1008.     ReplyMsg(message);
  1009. }
  1010.  
  1011.  
  1012. newsize(message, w)
  1013. struct IntuiMessage *message;
  1014. struct Window *w;
  1015. {
  1016. Move(w->RPort, 20, 10);
  1017. Draw(w->RPort, 110, 100);
  1018. }
  1019.  
  1020.  
  1021. SHORT pen = 0;
  1022.  
  1023. sizeverify(message, w)
  1024. struct IntuiMessage *message;
  1025. struct Window *w;
  1026. {
  1027.     SHORT count;
  1028.  
  1029. SetAPen(w->RPort, pen++);
  1030. Move(w->RPort, 10, 10);
  1031. Draw(w->RPort, 100, 100);
  1032.  
  1033.     printf("SIZE? Hmm...");
  1034.     for (count = 65535; count; count--) ;
  1035.     printf("Hmm...");
  1036.     for (count = 65535; count; count--) ;
  1037.     printf("Hmm...");
  1038.     for (count = 65535; count; count--) ;
  1039.     printf("Hmm...");
  1040.     for (count = 65535; count; count--) ;
  1041.     printf("OK!\n");
  1042.     ReplyMsg(message);
  1043.  
  1044. /*???return;*/
  1045.  
  1046.     printf("Hmm...");
  1047.     for (count = 65535; count; count--) ;
  1048.     printf("Hmm...");
  1049.     for (count = 65535; count; count--) ;
  1050.     printf("Hmm...");
  1051.     for (count = 65535; count; count--) ;
  1052.     printf("Hmm...");
  1053.     for (count = 65535; count; count--) ;
  1054.     printf("Hmm...");
  1055.     for (count = 65535; count; count--) ;
  1056.     printf("Hmm...");
  1057.     for (count = 65535; count; count--) ;
  1058.     printf("Hmm...");
  1059.     for (count = 65535; count; count--) ;
  1060.     printf("OK!\n");
  1061.     Request(&TestRequest[2], w);
  1062. }
  1063.  
  1064.  
  1065. SHORT closewindow(message, window, count)
  1066. struct IntuiMessage *message;
  1067. struct Window *window;
  1068. SHORT count;
  1069. {
  1070.     switch (--count)
  1071.         {
  1072.         case 2: 
  1073.             printf("are you sure you want to die?  I'll reply this time.\n");
  1074.             ReplyMsg(message);
  1075.             return(count);
  1076.             break;
  1077.         case 1: 
  1078.             printf("are you really really sure?\n");
  1079.             ReplyMsg(message);
  1080.             return(count);
  1081.             break;
  1082.         default:
  1083.             /* very bad of me.  I didn't Reply() to last the last message */
  1084.             printf("bye now.\n");
  1085.             ReplyMsg(message);
  1086.             CloseWindow(window);
  1087.             return(0);
  1088.         }
  1089. }
  1090.  
  1091.  
  1092.  
  1093. rjopenwindow(screen)
  1094. struct Screen *screen;
  1095. /* if the screen arg == NULL, this is still WorkBench */
  1096. {
  1097.     struct Task *task;
  1098.     SHORT i;
  1099.     LONG *stack;
  1100.     BYTE *aptr;
  1101.  
  1102.     if ((task = (struct Task *)AllocMem(sizeof(struct Task), 
  1103.             MEMF_CLEAR | MEMF_PUBLIC)) == 0)
  1104.         Panic("task alloc out of mem!");
  1105.     if ((stack = (LONG *)AllocMem(sizeof(LONG) * 1024, MEMF_CLEAR)) == 0)
  1106.         Panic("stack alloc out of mem!");
  1107.  
  1108. /*???    task->tc_Node.ln_Pri = 0;*/
  1109.     task->tc_Node.ln_Pri = 5;
  1110.     task->tc_SPReg = &stack[1023];
  1111.     task->tc_SPLower = stack;
  1112.     task->tc_SPUpper = &stack[1023];
  1113.     task->tc_Node.ln_Name = "WindowTask";
  1114.     /* pass the screen address as an argument to the procedure */
  1115.     stack[1023] = (LONG)screen;
  1116.  
  1117.     AddTask(task, windowtask, 0);
  1118. }
  1119.  
  1120.  
  1121. struct Screen *rjopenscreen()
  1122. {
  1123.     SHORT depth, lace;
  1124.     struct Screen *screen;
  1125.     struct NewScreen NewScreen;
  1126.  
  1127.     printf("about to open a LowRes Screen.  What depth should I use: ");
  1128.     depth = GetNum();
  1129.     printf("Want INTERLACE : "); lace = GetNum();
  1130.  
  1131.     NewScreen.LeftEdge = 0;
  1132.     NewScreen.TopEdge = 0;
  1133.     NewScreen.Width = 320;
  1134.     NewScreen.Depth = depth;
  1135.     NewScreen.Type = CUSTOMSCREEN;
  1136.     NewScreen.DetailPen = 1;
  1137.     NewScreen.BlockPen = 3;
  1138.     NewScreen.DefaultTitle = ScreenTitles[(screenindex++) & 0x3];
  1139.     if (lace)
  1140.         {
  1141.         NewScreen.ViewModes = INTERLACE;
  1142.         NewScreen.Height = 400;
  1143.         }
  1144.     else
  1145.         {
  1146.         NewScreen.ViewModes = NULL;
  1147.         NewScreen.Height = 200;
  1148.         }
  1149.     NewScreen.Font = &TestFont;
  1150.     NewScreen.Gadgets = NULL;
  1151.  
  1152.     screen = OpenScreen(&NewScreen);
  1153.  
  1154.     SetRGB4(&screen->ViewPort, 0, red++, green++, blue++);
  1155.     SetRGB4(&screen->ViewPort, 1, 15, 15, 15);
  1156.     SetRGB4(&screen->ViewPort, 2, blue, red, green);
  1157.     SetRGB4(&screen->ViewPort, 3, green, blue, red);
  1158.  
  1159.     blue++;
  1160.     green = (green + blue) & 0xF;
  1161.     red = (green + blue + red) & 0xF;
  1162.  
  1163.     return(screen);
  1164. }
  1165.  
  1166.  
  1167. struct Screen *autoopenscreen()
  1168. {
  1169.     SHORT depth, lace;
  1170.     struct Screen *screen;
  1171.     struct NewScreen NewScreen;
  1172.  
  1173.     depth = 3;
  1174.  
  1175.     NewScreen.LeftEdge = 0;
  1176.     NewScreen.TopEdge = 0;
  1177.     NewScreen.Width = 640;
  1178.     NewScreen.Depth = depth;
  1179.     NewScreen.Type = CUSTOMSCREEN;
  1180.     NewScreen.DetailPen = 1;
  1181.     NewScreen.BlockPen = 3;
  1182.     NewScreen.DefaultTitle = ScreenTitles[(screenindex++) & 0x3];
  1183.     NewScreen.ViewModes = HIRES;
  1184.     NewScreen.Height = 200;
  1185.     NewScreen.Font = &TestFont;
  1186.     NewScreen.Gadgets = NULL;
  1187.  
  1188.     screen = OpenScreen(&NewScreen);
  1189.  
  1190.     SetRGB4(&screen->ViewPort, 0, red++, green++, blue++);
  1191.     SetRGB4(&screen->ViewPort, 1, 15, 15, 15);
  1192.     SetRGB4(&screen->ViewPort, 2, blue, red, green);
  1193.     SetRGB4(&screen->ViewPort, 3, green, blue, red);
  1194.  
  1195.     blue++;
  1196.     green = (green + blue) & 0xF;
  1197.     red = (green + blue + red) & 0xF;
  1198.  
  1199.     return(screen);
  1200. }
  1201.  
  1202.  
  1203. main()
  1204. {
  1205. /* ==========================================================================
  1206.  * === OK, here's the real program! =========================================
  1207.  * ==========================================================================
  1208.  */
  1209.     struct Screen *workscreen;
  1210.     SHORT time, c, i, i2, error, dumpwidth, dumpheight;
  1211.     LONG longi;
  1212.     struct Window *w;
  1213.     struct RastPort *rp;
  1214.     ULONG Seconds, Micros;
  1215.     struct Preferences Prefs;
  1216.     struct View *View;
  1217.     struct ViewPort *vp;
  1218.  
  1219.     if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0)) == 0)
  1220.         Panic("Woah, no graphics library in main!");
  1221.  
  1222.     if ((IntuitionBase = (LONG *)OpenLibrary("intuition.library", 0)) == 0)
  1223.         Panic("Woah, no intuition library in main!");
  1224.  
  1225.     time = 0;
  1226.     workscreen = NULL;
  1227.     PropCount = 0;
  1228.     printf("&IBase->ActiveWindow=%lx\n",&IntuitionBase->ActiveWindow);
  1229.     printf("sizeof(IBase)=%lx\n", sizeof(struct IntuitionBase));
  1230.     printf("sizeof(Preferences)=%lx\n", sizeof(struct Preferences));
  1231.     printf("sizeof(IntuiMessage)=%lx\n", sizeof(struct IntuiMessage));
  1232.     printf("&ReqProp=%lx\n",&ReqProp);
  1233.  
  1234.     StartupScreen = workscreen = IntuitionBase->ActiveScreen;
  1235.     RecentWindow = IntuitionBase->ActiveWindow;
  1236.     dumpwidth = DUMP_WIDTH;
  1237.     dumpheight = DUMP_HEIGHT;
  1238.  
  1239. RESTART:
  1240.  
  1241.     while ((c = MayGetChar()) == -1) ;
  1242.  
  1243.     switch (c)
  1244.         {
  1245.         case 'A':
  1246.                 i = AutoRequest(RecentWindow, &BodyText1, &GoodText, &BadText,
  1247.                         DISKINSERTED, NULL, 320, 100);
  1248.                 printf("Result of AutoRequest()=%lx\n", i);
  1249.                 break;
  1250.         case 'b':
  1251.                 MoveScreen(workscreen, 0, -2);
  1252.                 break;
  1253.         case 'B':
  1254.                 MoveScreen(workscreen, 0, 2);
  1255.                 break;
  1256.         case 'c':       /* 'c' for crazy screen, to prove microsoft wrong */
  1257.                 i = 0;
  1258.                 while ((c = MayGetChar()) == -1)
  1259.                     {
  1260.                     workscreen = autoopenscreen(workscreen);
  1261.                     i++;
  1262.                     printf("\nscreen %ld:  press any key to quit:", i);
  1263.                     for (longi = 0; longi < HALFMILLION; longi++) ;
  1264.                     CloseScreen(workscreen);
  1265.                     }
  1266.                 break;
  1267.         case 'd':
  1268.                 Debug();
  1269.                 break;
  1270.         case 'D':
  1271.                 printf("&AlertString=%lx\n",&AlertString[0]);
  1272.                 DisplayAlert(RECOVERY_ALERT, AlertString, 49);
  1273.                 break;
  1274.         case 'e':
  1275.                 printf("Leaving now!  Bye.\n");
  1276.                 exit(TRUE);
  1277.         case 'p':
  1278.                 /* print the active window */
  1279.                 error = PrinterOpen(AllocSignal(-1));
  1280.                 if (error)
  1281.                     {
  1282.                     printf("Open Printer error=%ld\n", error);
  1283.                     break;
  1284.                     }
  1285.                 workscreen = IntuitionBase->ActiveScreen;
  1286.                 RecentWindow = IntuitionBase->ActiveWindow;
  1287.                 vp = &workscreen->ViewPort;
  1288.                 longi = (RecentWindow->Width  << 16) / RecentWindow->Height;
  1289.                 i = (dumpwidth * longi) >> 16;
  1290.                 error = PrintRPort(RecentWindow->RPort, 
  1291.                     vp->ColorMap, vp->Modes, 
  1292.                     0, 0, 
  1293.                     RecentWindow->Width, RecentWindow->Height,
  1294. /*???               dumpwidth, i, */
  1295.                     dumpwidth, dumpheight, 
  1296.                     0);
  1297.                 if (error) printf("The DUMP error # is %ld\n",error);
  1298.                 PrinterClose();
  1299.                 break;
  1300.         case 'P':
  1301.                 /* print the active screen */
  1302.                 error = PrinterOpen(AllocSignal(-1));
  1303.                 if (error)
  1304.                     {
  1305.                     printf("Open Printer error=%ld\n", error);
  1306.                     break;
  1307.                     }
  1308.                 workscreen = IntuitionBase->ActiveScreen;
  1309.                 vp = &workscreen->ViewPort;
  1310.                 printf("Short=0, Long=1:");
  1311.                 i = GetNum();
  1312.                 printf("\n");
  1313.                 if (i)
  1314.                     error = PrintRPort(&workscreen->RastPort,
  1315.                             workscreen->ViewPort.ColorMap, 
  1316.                             workscreen->ViewPort.Modes, 
  1317.                             0, 0, 
  1318.                             workscreen->Width, workscreen->Height, 
  1319.                             dumpwidth, dumpheight, 0);
  1320.                 else
  1321.                     error = PrintRPort(&workscreen->RastPort,
  1322.                             workscreen->ViewPort.ColorMap, 
  1323.                             workscreen->ViewPort.Modes, 
  1324.                             0, 0, 
  1325.                             workscreen->Width, workscreen->Height / 4,
  1326.                             dumpwidth, dumpheight / 4, 0);
  1327.                 if (error) printf("The DUMP error # is %ld\n",error);
  1328.                 PrinterClose();
  1329.                 break;
  1330.         case 'q':
  1331.                 Debug();
  1332.                 break;
  1333.         case 's':
  1334.                 workscreen = rjopenscreen(workscreen);
  1335.                 break;
  1336.         case 'S':
  1337.                 if (workscreen)
  1338.                     {
  1339.                     CloseScreen(workscreen);
  1340.                     workscreen = NULL;
  1341.                     }
  1342.                 else printf("No Screen opened yet!\n");
  1343.                 break;
  1344.         case 't':
  1345.                 TestITLength();
  1346.                 break;
  1347.         case 'T':
  1348.                 CurrentTime(&Seconds, &Micros);
  1349.                 printf("what are you waiting for?  Seconds=%ld Micros=%ld\n",
  1350.                         Seconds, Micros);
  1351.                 break;
  1352.         case 'v':
  1353.                 printf("CloseWorkBench()=%lx\n", CloseWorkBench());
  1354.                 break;
  1355.         case 'V':
  1356.                 printf("OpenWorkBench()=%lx\n", OpenWorkBench());
  1357.                 break;
  1358.         case 'w':
  1359.                 rjopenwindow(workscreen);
  1360.                 break;
  1361.         case 'W':
  1362.                 printf("0=8.5, 1=7.5, 2=6.5, 3=5.5, 4=4.5, other=select: ");
  1363.                 i = GetNum();
  1364.                 switch (i)
  1365.                     {
  1366.                     case 0:
  1367.                         dumpwidth = 1024;
  1368.                         dumpheight = 640;
  1369.                         break;
  1370.                     case 1:
  1371.                         dumpwidth = 904;
  1372.                         dumpheight = 565;
  1373.                         break;
  1374.                     case 2:
  1375.                         dumpwidth = 783;
  1376.                         dumpheight = 489;
  1377.                         break;
  1378.                     case 3:
  1379.                         dumpwidth = 663;
  1380.                         dumpheight = 414;
  1381.                         break;
  1382.                     case 4:
  1383.                         dumpwidth = 542;
  1384.                         dumpheight = 339;
  1385.                         break;
  1386.                     default:
  1387.                         printf("\nwidth:"); dumpwidth = GetNum();
  1388.                         printf("\nheight:"); dumpheight = GetNum();
  1389.                         break;
  1390.                     }
  1391.                 printf("\n");
  1392.                 break;
  1393.         case 'x':
  1394.                 DisplayBeep(NULL);
  1395.                 break;
  1396.         case 'z':
  1397.                 View = (struct View *)ViewAddress();
  1398.                 printf("DxOffset=%ld DyOffset=%ld\n",
  1399.                         View->DxOffset, View->DyOffset);
  1400.                 break;
  1401.                 break;
  1402.         default:
  1403.                 break;
  1404.         }
  1405.  
  1406.     goto RESTART;
  1407. }
  1408.